{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>
	</h1>
</div>

<form>	
<table class="table table-striped table-bordered table-hover search-form">
	<thead>
		
		<th>
			


			 <select name="exchange_id" style="width: 200px;"  id ="exchange_id"    tabindex="4">
                  <option value ="-1">--请选择交易所--</option>{volist name="exchange" id="p" empty="$exchange"}<option value ="{$p.id}" >{$p.name}</option>              
                  {/volist}  
            </select> 

			<select name="variety_id" id ="variety_id" style="width: 200px;"  " tabindex="4">
	                  <option value ="-1">--请选择交易品种--</option> 
	                      
	                 
            </select> 

			<input name="trade_dt" type="date" placeholder="日期" value="{:input('param.trade_dt')}" />

		</th>			
		<th>
			<a class="btn btn-primary" href="javascript:;" id="search" url="{:url('value/config')}">查询</a>
		<th>
			<a class="btn btn-primary" href="{:url('value/edit')}">维护收盘价</a>
		</th>
	</thead>

</table>	
	

					<th>
<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>

						<th>日期</th>
						<th>交易所</th>
						<th>交易品种</th>

						<th>收盘价</th> 
						

						<th>操作</th>	
					</tr>
				</thead>
				<tbody>
						{volist name="list" id="v" empty="$empty"}
						<tr>						
							<td>{$v.dt}</td>
							<td>
							{volist name="exchange" id="p" empty="$exchange"}
                  			   {if condition="$p.id eq $v.exchange_id"}
                  			       {$p.name}
                  			   {/if}            
                  			{/volist}
                  			</td>

                  			<td>
							{volist name="variety" id="p" empty="$variety"}
                  			   {if condition="$p.id eq $v.variety_id"}
                  			       {$p.name}
                  			   {/if}            
                  			{/volist}
                  			</td>
							<td>
							{$v.rate}
							</td>
							
							<td>
								
							</td>
							
						</tr>
						{/volist}	
						
						<tr>
							<td colspan="20" class="page">{$list->render()}</td>
						</tr>
				</tbody>
				
			</table>
		</div>
	</div>
</div>
</form>
{/block}
{block name="javascript"}
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	

      $("#current").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
</script>

<script type="text/javascript">
	$('#exchange_id').change(function(){
		//alert("abc");
		var iframe_array = <?php echo  json_encode($variety);   ?>;
    	var checkValue=jQuery("#exchange_id").val();
    	//alert(checkValue);
    	$("#variety_id").empty();  
    	for (var i = 0; i <iframe_array.length ; i++) 
    	{
    		if(iframe_array[i]['exchange_id']==checkValue)
	    	{
	    		var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
	    		jQuery("#variety_id").append(opt);
	    	}
	    }

	})

</script>
{/block}